package com.osfw.dbadminer.controller.operlog;

import com.github.pagehelper.PageInfo;
import com.osfw.dbadminer.entity.operlog.DbaOperLog;
import com.osfw.dbadminer.service.operlog.IDbaOperLogService;
import com.osfw.framework.core.controller.BaseController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 操作日志记录
 */
@Controller
@RequestMapping("/osfw/dbadminer/operlog")
public class DbaOperlogController extends BaseController {
    private String prefix = "osfw/dbadminer/operlog";

    @Autowired
    private IDbaOperLogService operLogService;

    @RequiresPermissions("dbadminer:operlog:view")
    @GetMapping()
    public String operlog() {
        return prefix + "/operlog";
    }

    @RequiresPermissions("dbadminer:operlog:list")
    @PostMapping("/list")
    @ResponseBody
    public PageInfo list(DbaOperLog operLog) {
        startPage(DbaOperLog.class);
        List<DbaOperLog> list = operLogService.selectOperLogList(operLog);
        return getPageInfo(list);
    }

}
